package com.damuzee.system.admin.service.impl;

import javax.annotation.Resource;

import org.mybatis.sql.condition.Criteria;
import org.mybatis.sql.page.Page;
import org.springframework.stereotype.Service;

import com.damuzee.system.admin.domain.EmpUser;
import com.damuzee.system.admin.persistence.EmpUserMapper;
import com.damuzee.system.admin.service.EmpUserService;

@Service
public class EmpUserServiceImpl implements EmpUserService {


	public EmpUser adminLogin(String userName, String password) {
		EmpUser user = new EmpUser();
		user.setUserName(userName);
		user.setUserPwd(password);
		return userMapper.select(user);
	}
	
	public Page<EmpUser> getEmpUserList(Page<EmpUser> page, Criteria cri) {
		 
		return userMapper.selectPageByCriteria(page, cri);
	}
	
	public Page<EmpUser> getEmpUserList(Page<EmpUser> page, EmpUser empUser) {
		 
		return userMapper.selectPageByWhere( page, empUser);
	}
	
	public void saveUser(EmpUser user2) {
		long lt = System.currentTimeMillis();
		for(int i = 0; i<10000;i++){
			EmpUser user = new EmpUser();
			user.setUserName("admin"+i);
			user.setEmail("yanwan199@163.com");
			user.setUserPwd("admin111111");
			user.setBirthday("1908-08-07");
			user.setEntryTime("1908-08-06");
			user.setTelephone("18708166683");
			user.setRealName("wh"+i);
		
			try {
				userMapper.save(user); 
				System.out.println(user.getIdKey());
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public void saveUser2(EmpUser user) {
				userMapper.save(user); 
	}
	
	public EmpUserMapper getAdminUserMapper() {
		return userMapper;
	}

	public void setAdminUserMapper(EmpUserMapper userMapper) {
		this.userMapper = userMapper;
	}

	 
	public EmpUser getAdminUser(EmpUser user) {
		 
		return userMapper.select(user);
	}

	@Resource
	private EmpUserMapper userMapper ;
	 
}